 /**
This file is part of Studentport.

    Studentport is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Studentport is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Studentport.  If not, see <http://www.gnu.org/licenses/>.

**/
package com.groupalpha.studentport;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

import com.httpclasses.HtmlHelper;

/**
 * 
 * will present the user with a choice (2buttons) and launch the activity chosen.
 * @author GroupAlpha
 *
 */
public class LunchChoiceEN extends Activity{
	static boolean Show = true;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lunchc);        
        
        final Button johanneberg = (Button) findViewById(R.id.button1);
        final Button lindholmen = (Button) findViewById(R.id.button2);
        final Button kokboken = (Button) findViewById(R.id.button4);
        final Button pripps = (Button) findViewById(R.id.button5);
        final Button logoffButton = (Button) findViewById(R.id.logoff);
        logoffButton.setBackgroundResource(R.drawable.logoff_button_en);
        
        final ProgressDialog dialog = new ProgressDialog(LunchChoiceEN.this);
        dialog.setCancelable(true);
        
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
			
			@Override
			public void onDismiss(DialogInterface dialog) {
				// TODO Auto-generated method stub
				Show = false;
			}
		});
        lindholmen.setOnClickListener(new View.OnClickListener() {
        	
            public void onClick(View v) {
            	Show = true;
            	String url2 = "http://cm.lskitchen.se/lskitchen/rss/weeken";
            	Intent i = new Intent("com.groupalpha.studentport.LUNCHL").putExtra("URL", url2).putExtra("Eng", true);
            	if(Show == true)
            	startActivity(i);
            }
        });
        
        johanneberg.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	Show = true;
            	String url2 = "http://cm.lskitchen.se/johanneberg/rss/weeken";
            	Intent i = new Intent("com.groupalpha.studentport.LUNCHL").putExtra("URL", url2).putExtra("Eng", true);
            	if(Show == true)
            	startActivity(i);            	
            }
        });
        
        
        kokboken.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	dialog.show();
            	LunchChoiceEN.Show = true;
            	dialog.setMessage("Loading Kokboken...");
            	Thread T = new Thread(){public void run(){
            	String url2 = "http://cm.lskitchen.se/lskitchen/rss/index/9/en";
            	Intent i = new Intent("com.groupalpha.studentport.LUNCHL").putExtra("URL", url2).putExtra("Eng", true);
            	if(Show == true){
            	dialog.dismiss();
  				LunchChoiceEN.this.startActivity(i);
            	}
            	}};
  				T.start();
            	
            	
            }
        });
        
        pripps.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	dialog.show();
            	LunchChoiceEN.Show = true;
            	dialog.setMessage("Loading J.A Prips...");
            	Thread T = new Thread(){public void run(){
            	       String url2 = HtmlHelper.getURLLunch(HtmlHelper.PRIPSEN);
                       String url = "https://docs.google.com/gview?enbedded=true&url="+url2;
                       Intent i = new Intent("com.groupalpha.studentport.NEWSBROWSER").putExtra("adress", url).putExtra("Eng", true);
            	if(Show == true){
            	dialog.dismiss();
            	LunchChoiceEN.this.startActivity(i);
            	}
            	}};
            	T.start();
            }
        });
        
        logoffButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	Intent intent = new Intent(LunchChoiceEN.this, StudentportActivity.class); 
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Removes other Activities from stack 
				startActivity(intent);
            }
            });
    }
}
